#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>

int main()
{
	
	printf("I am father process, pid: %d, ppid: %d\n",getpid(),getppid());
	printf("\n");
	pid_t id = fork();
	
	if (id == -1)
	{
		perror("fork failed!");
	}
	else if(id == 0)
		printf("I am child process, pid: %d, ppid: %d\n",getpid(),getppid());
	else
	{
		printf("I am father process, pid: %d, ppid: %d\n",getpid(),getppid());
		wait(NULL);    //等待子进程结束
	}
	return 0;
}
